2 Problem: 270 - Lining up
3 Andrés Mejía-Posada (andmej@gmail.com)
27 #define D(x) cout << #x " is " << x << endl
31 point(int x
=0, int y
=0) : x(x
), y(y
) {}
34 void simplify(pair
<int, int> &p
){
37 assert(p
.x
!= 0 || p
.y
!= 0);
46 int sign
= ((p
.x
<0)^(p
.y
<0) ? -1 : 1);
47 p
.x
= abs(p
.x
), p
.y
= abs(p
.y
);
48 int g
= __gcd(p
.x
, p
.y
);
49 if (g
) p
.x
/= g
, p
.y
/= g
;
59 getline(cin
, s
), getline(cin
, s
);
62 while (getline(cin
, s
) && s
!= ""){
64 sscanf(s
.c_str(), "%d %d", &_
.x
, &_
.y
);
69 map
<pair
<int, int>, int> cnt
;
70 const int n
= p
.size();
71 for (int i
=0; i
<n
; ++i
){
72 for (int j
=i
+1; j
<n
; ++j
){
73 pair
<int, int> slope(p
[j
].y
- p
[i
].y
, p
[j
].x
- p
[i
].x
);
75 map
<pair
<int, int>, int>::iterator i
= cnt
.find(slope
);
76 if (i
!= cnt
.end()) x
= max(x
, ++i
->second
);
77 else x
= max(x
, cnt
[slope
] = 2);
80 cout
<< (int)((1 + sqrt(1 + 8*x
))/2) << endl
;
81 if (casos
> 0) cout
<< endl
;